package com.zhss.eshop.wms.mapper;

import com.zhss.eshop.wms.domain.model.WmsGoodsStock;
import org.apache.ibatis.annotations.*;

@Mapper
public interface WmsGoodsStockMapper {
    int deleteByPrimaryKey(Long id);

    int insertSelective(WmsGoodsStock record);

    WmsGoodsStock selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(WmsGoodsStock record);
    /**
     * 根据商品sku id查询商品库存
     * @param goodsSkuId 商品sku id
     * @return 商品库存
     */
    @Select("SELECT "
            + "id,"
            + "goods_sku_id,"
            + "available_stock_quantity,"
            + "locked_stock_quantity,"
            + "output_stock_quantity,"
            + "gmt_create,"
            + "gmt_modified "
            + "FROM wms_goods_stock "
            + "WHERE goods_sku_id=#{goodsSkuId}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "goods_sku_id", property = "goodsSkuId"),
            @Result(column = "available_stock_quantity", property = "availableStockQuantity"),
            @Result(column = "locked_stock_quantity", property = "lockedStockQuantity"),
            @Result(column = "output_stock_quantity", property = "outputStockQuantity"),
            @Result(column = "gmt_create", property = "gmtCreate"),
            @Result(column = "gmt_modified", property = "gmtModified")
    })
    WmsGoodsStock getBySkuId(@Param("goodsSkuId") Long goodsSkuId);
}
